﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace Nollie.Utilities
{
	public class SerializationHelper
	{
		public static byte[] SerializeObject(object value)
		{
			using (var stream = new MemoryStream())
			{
				var formatter = new BinaryFormatter();

				formatter.Serialize(stream, value);

				return stream.ToArray();
			}
		}
		public static object DeserializeObject(byte[] serializedValue)
		{
			using (var stream = new MemoryStream(serializedValue))
			{
				var formatter = new BinaryFormatter();

				return formatter.Deserialize(stream);
			}
		}
	}
}
